package com.xc.controller;

import com.github.pagehelper.PageInfo;
import com.xc.pojo.Student;
import com.xc.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 星晨
 */
@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/list")
    public String queryAllByPage(@RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
                                 @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize,
                                 Model model){
        PageInfo<Student> studentPageInfo = studentService.queryAllByPage(pageNum, pageSize);
//        System.out.println(studentPageInfo);
//        System.out.println(studentPageInfo.getList());
//        System.out.println(studentPageInfo.getList().indexOf(1)+1);
        model.addAttribute("studentPageInfo",studentPageInfo);
        return "list";
    }

}
